﻿-- =============================================
-- Script Template
-- =============================================
DROP SYMMETRIC KEY [SYM_KEY]
GO
CREATE SYMMETRIC KEY [SYM_KEY]
    AUTHORIZATION [dbo]
    WITH ALGORITHM = TRIPLE_DES
    ENCRYPTION BY PASSWORD = N'##CLAB##';

DECLARE @KEYID UNIQUEIDENTIFIER
DECLARE @sPass NVARCHAR(2000), @sPassword NVARCHAR(200)
SET @KEYID = KEY_GUID('SYM_KEY')
	 
OPEN SYMMETRIC KEY SYM_KEY
DECRYPTION BY PASSWORD='##CLAB##'

SET @sPassword = 'adminlab'
SELECT @sPass = ENCRYPTBYKEY(@KEYID,@sPassword)
SELECT @sPass

DELETE FROM CatUsuario
Insert into CatUsuario(IdUsuario, IdLaboratorio, UserName, Password, IdEstatus, IdSucursal)
Values(1,1,'adminlab',@sPass,1,1)

-- Recepción 1
SET @sPassword = 'recepcion'
SELECT @sPass = ENCRYPTBYKEY(@KEYID,@sPassword)

Insert into CatUsuario(IdUsuario, IdLaboratorio, UserName, Password, IdEstatus, IdSucursal)
Values(2,1,'recepcion',@sPass,1,1)

-- Quimico
SET @sPassword = 'quimico'
SELECT @sPass = ENCRYPTBYKEY(@KEYID,@sPassword)

Insert into CatUsuario(IdUsuario, IdLaboratorio, UserName, Password, IdEstatus, IdSucursal)
Values(3,1,'quimico',@sPass,1, 1)